/*
 * Copyright (C), 2002-2016, 上海亦寻信息技术有限公司
 * FileName: PinController.java
 * Author:   linyao
 * Date:     2016-6-24 下午3:45:18
 * Description: //模块目的、功能描述      
 * History: //修改记录
 * <author>      <time>      <version>    <desc>
 * 修改人姓名             修改时间            版本号                  描述
 */
package com.emm.yixun.website.controller.marketing;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.emm.yixun.common.model.User;
import com.emm.yixun.common.response.Response;
import com.emm.yixun.system.service.MerchantServiceFacade;
import com.emm.yixun.website.common.utils.security.ShiroUtil;
import com.emm.yixun.website.constant.ConstantConfig;
import com.emm.yixun.website.controller.base.BaseController;

/**
 * 〈一句话功能简述〉 〈功能详细描述〉
 * 
 * @author linyao
 * @see [相关类/方法]（可选）
 * @since [产品/模块版本] （可选）
 */
@Controller
@RequestMapping("/marketing/pin/")
public class PinController extends BaseController<Object>{

	@Autowired
	private MerchantServiceFacade merchantServiceFacade;
	
	@Autowired
	private ConstantConfig constantConfig;
	
	@RequestMapping("index")
	public ModelAndView index(HttpServletRequest request) {
		request.setAttribute("permitBtn", getPermissionBtnArray());
		request.setAttribute("menu", request.getParameter("menu"));
		User user = ShiroUtil.getCurrentUser();
		
		//认筹开关,默认未关闭
		boolean payDepositOff = false;
		Response<Boolean> response = merchantServiceFacade.merPayDepositOff(user.getMerchantId());
		if(response.isSuccess()){
			payDepositOff = response.getEntity();
		}
		
		request.setAttribute("userName", user.getUserName());
		return new ModelAndView("/marketing/pin/list")
		.addObject("payDepositOff", payDepositOff)
		.addObject("templet", constantConfig.getSubscribeTemplet())
		.addObject("templet_cw", constantConfig.getSubscribeTempletCw());

	}
	
	@RequestMapping("haveReceive")
	public ModelAndView haveReceive(HttpServletRequest request,String receivablesType,String returnBackParam) {
		request.setAttribute("relationId", request.getParameter("relationId"));
		request.setAttribute("returnBackParam", returnBackParam);
		request.setAttribute("receivablesType", receivablesType);
		return new ModelAndView("/marketing/pin/haveReceiveList");

	}
}
